<?php

namespace App\Http\Controllers;

use App\Library\Requests\Base\BasePageRequest;
use App\Library\Requests\Base\SerialNumberRequest;
use App\Library\Requests\UserAddress\UserAddressAddRequest;
use App\Library\Requests\UserAddress\UserAddressEditRequest;
use App\Library\Service\UserAddressService;
use Illuminate\Http\JsonResponse;

class UserAddressController extends BaseController
{
    /**
     * @param UserAddressService $service
     */
    public function __construct(UserAddressService $service)
    {
        $this->service = $service;
    }

    /**
     * 分页
     * @param BasePageRequest $request
     * @return JsonResponse
     *
     */
    public function paging(BasePageRequest $request): JsonResponse
    {
        return $this->service->paging($request);
    }

    /**
     * 添加
     * @param UserAddressAddRequest $request
     * @return JsonResponse
     *
     */
    public function add(UserAddressAddRequest $request): JsonResponse
    {
        return $this->service->add($request);
    }

    /**
     * 编辑
     * @param UserAddressEditRequest $request
     * @return JsonResponse
     *
     */
    public function edit(UserAddressEditRequest $request): JsonResponse
    {
        return $this->service->edit($request);
    }

    /**
     * 删除
     * @param SerialNumberRequest $request
     * @return JsonResponse
     *
     */
    public function delete(SerialNumberRequest $request): JsonResponse
    {
        return $this->service->delete($request);
    }

    /**
     * 获取用户默认收货地址
     * @return JsonResponse
     *
     */
    public function default(): JsonResponse
    {
        return $this->service->default();
    }
}
